//
//  CreatModelMutTool.m
//  房源、商铺、写字楼详情页
//
//  Created by MB__Lee on 2018/5/23.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "CreatModelMutTool.h"

#import "coCellModel.h"

@implementation CreatModelMutTool
+(NSMutableArray *)creatModelToolCreatWithArray:(NSArray *)array{
    
    NSMutableArray *mut  = [NSMutableArray arrayWithCapacity:10];
    
    //1.将服务器返回的数据拼接成 字符串
    NSString *JoinedStr  = [array componentsJoinedByString:@""];
    
    //2.检索要用到数组  ---本地数据
    NSArray *originalArr  = @[@"电视",@"冰箱",@"洗衣机",@"热水器",@"空调",@"微波炉",@"床",@"衣柜",@"沙发",@"宽带"];
    

    
    //3.本地图片名称
    NSArray *seletedImageMut = @[@"电视",@"冰箱",@"洗衣机",@"热水器",@"空调",@"微波炉",@"床",@"衣柜",@"沙发",@"宽带"];
    NSArray *noSelectedImageMut  = @[@"TV_icon_not",@"bingxiang_icon_not",@"xiyiji_icon_not",@"reshuiqi_icon_not",@"kongtiao_icon_not",@"weibolu_icon_not",@"chuang_icon_not",@"yigui_icon_not",@"shafa_icon_not",@"wifi_icon_not"];
    
    int i = 0;
    //3.将本地数组 中的元素，在拼接字符串中进行检索、然后生成模型
    for (NSString *name in originalArr) {
        
        coCellModel *coModel  = [[coCellModel alloc] init];
        coModel.name = originalArr[i];
        coModel.selected = seletedImageMut[i];
        coModel.noSelected = noSelectedImageMut[i];
        if ([JoinedStr containsString:name]) {
            coModel.isSlected = YES;
        }else{
            coModel.isSlected = NO;
        }
        i+=1;
        NSLog(@"====%zd",i);
        [mut addObject:coModel];
    }
    
    
    
    return mut;
}

@end
